package com.mao.jxc.admin.interceptor;


import com.mao.jxc.admin.pojo.User;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author: Administrator
 * @description:
 * @cteate 2021-07-21-22:24
 */
public class NoLoginInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        User user = (User) request.getSession().getAttribute("user");
        if (null == user){
            response.sendRedirect("/index");
            return false;
        }
        return true;
    }
}
